<template>
  <div class="app-container">
    <el-form ref="form" :model="author" label-width="120px">
      <!--    隐藏域 记录id-->
      <input type="hidden" v-model="author.id"/>
      <el-form-item label="姓名">
        <el-input v-model="author.name" />
      </el-form-item>
      <el-form-item label="生日">
        <el-date-picker style="width: 100%" v-model="author.birthday" type="date" placeholder="选择出生日期"/>
      </el-form-item>
      <el-form-item label="性别">
        <el-radio-group v-model="author.sex">
          <el-radio label="男" aria-checked="true"/>
          <el-radio label="女" />
        </el-radio-group>
      </el-form-item>
      <el-form-item label="学历">
        <el-select v-model="author.edu" placeholder="请选择学历信息">
          <el-option label="博士" value="博士" />
          <el-option label="研究生" value="研究生" />
          <el-option label="本科" value="本科" />
          <el-option label="专科" value="专科" />
          <el-option label="高中及以下" value="高中" />
        </el-select>
      </el-form-item>
      <el-form-item label="家乡">
        <el-select v-model="author.city" placeholder="请选择家乡">
          <el-option label="河南" value="河南" />
          <el-option label="河北" value="河北" />
          <el-option label="新疆" value="新疆" />
          <el-option label="宁夏" value="宁夏" />
          <el-option label="湖南" value="湖南" />
          <el-option label="湖北" value="湖北" />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="部门">-->
<!--        <el-select v-model="author.did" placeholder="请选择部门">-->
<!--          <el-option label="人力资源部" value="2" />-->
<!--          <el-option label="财务部" value="3" />-->
<!--        </el-select>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="职位">-->
<!--        <el-select v-model="author.job" placeholder="请选择职位">-->
<!--          <el-option label="实习" value="实习" />-->
<!--          <el-option label="作者" value="员工" />-->
<!--          <el-option label="骨干" value="骨干" />-->
<!--          <el-option label="Leader" value="Leader" />-->
<!--          <el-option label="经理" value="经理" />-->
<!--          <el-option label="总经理" value="总经理" />-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary"  @click="onSubmit">修改作者</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      author: {
        name: '',
        birthday: '',
        job:'',
        city:'',
        did:2,
        sex:'',
        edu:''
      }
    }
  },
  mounted() {
    this.author=this.$store.state.user.author;
  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url:"/author/update.do",
        method: "POST",
        data:this.author
      }).then(res=>{
        if(res.code==0){
          //跳转到列表页面
          this.$router.push("/authorlist");
        }
      })
    },
    onCancel() {
      this.$router.push("/authorlist");
      this.$message({
        message: 'cancel!',
        type: 'warning'
      });
      this.$router.push("/authorlist");
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

